﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cmd
{
    internal class CommandLineOptionEqComparer : IEqualityComparer<CommandLineOption>
    {
        public bool Equals(CommandLineOption x, CommandLineOption y)
        {
			return (x.Command == y.Command ||
				x.Command == y.Alias ||
				x.Alias == y.Command ||
                (x.Alias == y.Alias && !string.IsNullOrWhiteSpace(x.Alias) && !string.IsNullOrWhiteSpace(y.Alias)));
        }

        public int GetHashCode(CommandLineOption obj)
        {
			return obj.Command.GetHashCode() * (string.IsNullOrWhiteSpace(obj.Alias) ? 1 : obj.Alias.GetHashCode());
        }
    }
}
